 <?php
 session_start();
 include_once ("Login/databaseconnection.php");
 $current_table="deleted_exam";
 date_default_timezone_set("Europe/Paris");
  	$t_d=date("Y/m/d");
$School_Id=$_GET['School_Id'];
   $Exam_Name=$_GET['Exam_Name'];
$Subject=$_GET['Subject'];
   $Year=$_GET['Year'];
   $sqlre=mysql_query("SELECT * FROM deleted_exam");
	if(mysql_num_rows($sqlre)!=0)
	{
$Subject=$_POST['Subject'];
		$School_Id=$_POST['School_Id'];
		$Exam_Name=$_POST['Exam_Name'];
		$Year=$_POST['Year'];
    $No_Of_Sat_Students=$_POST['No_Of_Sat_Students'];
    $No_Of_Passed_Students=$_POST['No_Of_Passed_Students'];
    $Last_Updated_Date=$_POST['Last_Updated_Date'];
	$Accessed_By=$_POST['Accessed_By'];
	$_SESSION['Accessed_By']=$Accessed_By;
	$sql=mysql_query("INSERT INTO exam(School_Id,Exam_Name,Subject,Year,No_Of_Sat_Students,No_Of_Passed_Students,Last_Updated_Date)VALUES('$School_Id','$Exam_Name','$Subject','$Year','$No_Of_Sat_Students','$No_Of_Passed_Students','$t_d')");
if($sql)
{  $resultdel=mysql_query("DELETE FROM deleted_exam WHERE Exam_Name='$Exam_Name' AND year='$Year' AND School_Id='$School_Id' AND Subject='$Subject'");
  if(!$resultdel)
{
$sql=mysql_query("INSERT INTO exam(School_Id,Exam_Name,Year,No_Of_Sat_Students,No_Of_Passed_Students,Last_Updated_Date) VALUES('$School_Id','$Exam_Name','$Subject','$Year','$No_Of_Sat_StSubject,udents','$No_Of_Passed_Students','$t_d')");
	 $_SESSION['error']="but this record is not removed from the recycle bin!";
}
$_SESSION['error']="Successfully restored!";
}
   if(!$sql)
{
	 $_SESSION['error']="Sorry,an error occured  please try again!";
}	
}
?>
